fix: generate macros for all subpackages#16955
Draft
Conversation
PawelWMS
commented
Apr 30, 2026
| %global target_kernel_release %azl_kernel_hwe_release | ||
| %global target_mlnx_ofa_kernel_version %azl_mlnx_ofa_kernel_hwe_version | ||
| %global target_mlnx_ofa_kernel_release %azl_mlnx_ofa_kernel_hwe_release | ||
| %global target_mlnx_ofa_kernel_version %azl_mlnx_ofa_kernel_hwe_modules_version |
Contributor
Author
There was a problem hiding this comment.
Switch to the correct name of the macro after the toolkit update. Not an actual change to the version passed during the build, thus no release bump.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #15578.
Summary
Fixes a bug in
versionsprocessorwhere the generatedmacros.releaseversionsfile only contained macros for the default (top-level) package of each spec, missing all subpackages with their own version, release, or epoch. Also fixes a related bug where every macro for a given spec was keyed off the spec file name, so subpackages with names different from the spec name effectively never received their own macros (each subpackage would just overwrite the default package's%azl_<spec>_*macros).Bug 1: only the default package was queried
In
processSpecFile()(toolkit/tools/versionsprocessor/versionsprocessor.go), the spec query was issued withrpm.QueryHeaderArgument(--srpm):The
--srpmflag instructsrpmspecto return only the source package header. Even though the surrounding code loops overpackagesexpecting one entry per built RPM, the query only ever returns a single line for the SRPM's own NEVR. As a result, no%azl_<subpackage>_*macros were emitted for any subpackage declared via%package— only the default package got macros.This was raised during the original review of #15578 (review comment) but the switch to
--builtrpmswas not applied, only the query format and regex changes.Bug 2: subpackage macros used the spec file name
processPackageVersionStringderived the macro name from the spec file's base name (e.g.kernel.spec→%azl_kernel_*) and then iterated over every queried package. Even after fixing Bug 1, every subpackage of a given spec would still write to the same%azl_<spec>_*macros, repeatedly overwriting the default package's values. Subpackages whose names differ from the spec name (e.g.kernel-headers,ca-certificates-shared,mlnx-ofa_kernel-devel) never produced their own dedicated macros.Fix (toolkit changes)
rpm.QuerySPEC(... QueryHeaderArgument)torpm.QuerySPECForBuiltRPMs. This makesrpmspecreturn one line per binary RPM that would be built from the spec, including all subpackages with their individual epoch/version/release.%{nevra}output, instead of from the spec file's base name. Each subpackage now gets its own%azl_<subpackage>_*set of macros.rpmSpecBuiltRPMRegex/RpmSpecBuiltRPMRegexfromrpmssnapshotby promoting it intointernal/rpm(along with its index constants), and extend it to capture the optional epoch and to split version and release into separate groups.rpmssnapshotnow consumes the shared regex and keeps its existingRepoPackage.Versionshape (epoch:version-release) by recombining the split groups.processPackageVersionStringno longer needs the spec file name or the dist tag: the package name comes from the regex, and the release no longer carries the dist tag (dist is its own capture group now), so the manualstrings.Replace(release, distTag, "", 1)is gone.processPackageVersionStringand into the caller (processSpecFile), where the spec file name is still in scope.--srpmfor arch checks etc. are untouched.After the fix, e.g.
ca-certificates.specyields macros forca-certificates,ca-certificates-shared,ca-certificates-base,ca-certificates-tools, andca-certificates-legacy— each with their own%azl_<subpackage>_version/_release(and_epochwhen non-zero) — instead of just the default package.Spec consumer updates
Because the macro names are now keyed off the built RPM's name rather than the spec file's base name, any consumer that referenced a
%azl_<spec_basename>_*macro for a spec whose default top-level package is not actually built had to be updated. The only such case in the corpus ismlnx-ofa_kernel-hwe.spec, which produces onlymlnx-ofa_kernel-hwe-modulesandmlnx-ofa_kernel-hwe-devel(no defaultmlnx-ofa_kernel-hweRPM, since the top-level package has no%filessection).The 10 spec consumers that referenced the (no-longer-produced)
%azl_mlnx_ofa_kernel_hwe_{version,release}macros now reference%azl_mlnx_ofa_kernel_hwe_modules_{version,release}instead:SPECS/{srp-hwe,iser-hwe,isert-hwe,mlnx-nfsrdma-hwe,xpmem-hwe}.specSPECS-SIGNED/{srp-hwe-signed,iser-hwe-signed,isert-hwe-signed,mlnx-nfsrdma-hwe-signed,xpmem-hwe-modules-signed}.specAll other
%azl_*_*macros currently in use across the corpus (%azl_kernel_*,%azl_kernel_hwe_*,%azl_mlnx_ofa_kernel_*) refer to packages that do have%filessections in their producing spec files, so they remain valid.Tests
RpmSpecBuiltRPMRegexfromrpmssnapshot_test.gointorpm_test.go, where the regex now lives.versionsprocessor_test.gofor the newprocessPackageVersionStringsignature (NEVRA input, nospecFileName/distTagarguments). Added a noarch case and an explicit subpackage-name assertion inTestProcessSpecFile_WithSubpackages, which now verifies distinct%azl_multipkg_*,%azl_multipkg_devel_*, and%azl_multipkg_libs_*macros.rpmssnapshot_test.gofor the expanded regex (epoch group added, version/release split) and added an epoch-bearing input toTestGenerateResults.internal/rpm,pkg/rpmssnapshot,versionsprocessor) pass withgo test. The fulltoolkit/toolstest run is otherwise green; the only failure isinternal/pkggraph/TestReferenceDOTFile, which fails identically onorigin/3.0-devand is unrelated to this PR.